﻿@{
    ViewBag.Title = "白名单列表";
}
@using PagedList
@using PagedList.Mvc
@model PagedList.IPagedList<zqdn.Web.ViewModels.DoctorFilterViewModel>

<div class="pageheader">
    <h2><i class="fa fa-user"></i> 白名单列表 </h2>
</div>

<div class="contentpanel">
    <div class="row">
        <a href="/admin/DoctorFilter/Create" class="btn btn-primary">添加白名单</a>
    </div>
    <div class="row form-group">
        <div class="col-3 pull-right" style="margin:0 5px;">
            <button class="btn btn-primary" id="search">查找</button>
        </div>
        <div class="col-3 pull-right">
            <input placeholder="手机号" class="form-control docMobile" />
        </div>
    </div>
    <div class="row">
        <div class="table-responsive">
            <table class="table table-hidaction table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>姓名</th>
                        <th>医院</th>
                        <th>手机</th>
                        <th>创建日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                  @foreach (var item in Model)
                    {
                        <tr>
                            <td>@item.ID</td>
                            <td>@item.Name</td>
                            <td>@item.Hospital</td>
                            <td>@item.Mobile</td>
                            <td>@item.CreatedTime.ToShortDateString()</td> 
                            <td>
                                <a href="/admin/DoctorFilter/edit?id=@item.ID">编辑</a>&nbsp;&nbsp;
                                <a href="javascript:void(0);"class="delete" data-dfid="@item.ID">删除</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div><!-- table-responsive -->
        @Html.PagedListPager((PagedList.IPagedList)Model, page => Url.Action("Index", new
                           {
                               page,
                               docMobile = ViewBag.docMobile
                           })
                            , PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
                            new PagedListRenderOptions()
                            {
                                LinkToPreviousPageFormat = "上一页",
                                LinkToNextPageFormat = "下一页",
                                MaximumPageNumbersToDisplay = 5
                            }, new AjaxOptions()
                            {
                                HttpMethod = "GET"
                            }))
    </div><!-- row -->
</div>

<script type="text/javascript">
    $(function() {
        $(".delete").on("click", function () {
            var id = $(this).attr("data-dfID");
            var del = window.confirm("是否确定删除该记录？");

            if(del){
                $.post("/admin/DoctorFilter/delete", { id: id }, function (data) {
                    if (data.Result == "success") {
                        location.reload();
                    }
                });
            }
        });
        $("#search").on("click", function () {
            var docMobile = $(".docMobile").val();
            var url = "/Admin/DoctorFilter?docMobile=" + docMobile;
            window.location.href = url;

        });
    })
</script>

 